/*package com.bj58.groupbuy.action.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.Number;
import jxl.write.NumberFormat;
import jxl.write.NumberFormats;
import jxl.write.WritableCell;
import jxl.write.WritableCellFormat;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;

*//**
 * @author Administrator
 * 
 *//*
public class ExcelUtil {
	private ReflectUtil reflectUtil = new ReflectUtil();

	*//**
	 * 下载EXCEL
	 * 
	 * @param request
	 * @param response
	 * @param WritableWorkbook
	 *//*
	public static void downLoadExcel(HttpServletRequest request,
			HttpServletResponse response, String fileName, WritableWorkbook wb) {
		try {
			fileName = URLEncoder.encode(fileName, "UTF-8");
			response.setContentType("application/x-download");
			response.addHeader("Content-Disposition", "attachment; filename="
					+ new String(fileName.getBytes("GBK"), "ISO-8859-1")
					+ ".xls");
			response.setContentType("application/vnd.ms-excel;charset=UTF8");
			wb.write();
			wb.close();
			response.flushBuffer();

		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	*//**
	 * 通用报表excel下载
	 * 
	 * @param <T>
	 * @param excelname
	 *            表格名称
	 * @param response
	 * @param titles
	 *            报表列标题
	 * @param rsList
	 *            查询结果的vo集合
	 * @param Class
	 *            <T> vo clazz
	 * @return
	 *//*
	*//**
	 * @param <T>
	 *            通用报表excel下载 & 生成文件
	 * @param excelname
	 *            表格名
	 * @param response
	 *            不为NULL则直接返回WWB以供下载 为NULL则配合pathName生成EXCEL文件
	 * @param titles
	 *            表格标题
	 * @param rsList
	 *            数据集
	 * @param clazz
	 * @param pathName
	 *            EXCEL文件生成路径 为""则不生成
	 * @return
	 *//*
	@SuppressWarnings("finally")
	public static <T> WritableWorkbook writeExcelCommon(String excelname,
			HttpServletResponse response, String[] titles, List<T> rsList,
			Class<T> clazz, String pathName) {
		try {
			WritableWorkbook wwb = null;
			if (null != response) {
				OutputStream os = response.getOutputStream();
				wwb = Workbook.createWorkbook(os);
			} else {
				wwb = Workbook.createWorkbook(new File(pathName));
			}

			Map<Integer, List<T>> rsMap = new HashMap<Integer, List<T>>();
			int sheetMaxNum = 60000;
			if (rsList.size() > sheetMaxNum) {
				int sheetCount = rsList.size() / sheetMaxNum;
				if (rsList.size() % sheetMaxNum > 0) {
					sheetCount++;
				}
				for (int i = 0; i < sheetCount; i++) {
					int beginIndex = i * sheetMaxNum;
					int endIndex = (i + 1) * sheetMaxNum;
					if (endIndex > rsList.size()) {
						endIndex = rsList.size();
					}
					rsMap.put(i, rsList.subList(beginIndex, endIndex));
				}
			} else {
				rsMap.put(0, rsList);
			}
			Iterator<Integer> rsKey = rsMap.keySet().iterator();

			// WritableCellFormat 数字格式问题处理
			List<WritableCellFormat> wcfList = getWCFList();

			while (rsKey.hasNext()) {
				int sheetNum = rsKey.next();
				List<T> subrsList = rsMap.get(sheetNum);
				String sheetName = "";
				if (sheetNum == 0) {
					sheetName = excelname;
				} else {
					sheetName = excelname + "_" + sheetNum;
				}
				WritableSheet ws = wwb.createSheet(sheetName, sheetNum);
				// 写列标
				Label label = new Label(0, 0, titles[0]);
				ws.addCell(label);
				for (int i = 1; i < titles.length; i++) {
					label = new Label(i, 0, titles[i]);
					ws.addCell(label);
				}
				// 写内容
				Method[] mm = clazz.getMethods();
				Map<String, Method> methodMap = new HashMap<String, Method>();
				for (Method m : mm) {
					methodMap.put(m.getName(), m);
				}

				Field[] fields = clazz.getDeclaredFields();
				for (int i = 0; i < subrsList.size(); i++) {
					T vo = subrsList.get(i);
					int ind = 0;
					for (int j = 0; j < fields.length; j++) {
						Class<?> filedCls = fields[j].getType();// 字段类型
						int isRate = 0;// 是否为百分比 默认不是

						String value = "";
						String methodName = "get"
								+ fields[j].getName().substring(0, 1)
										.toUpperCase()
								+ fields[j].getName().substring(1);
						if (clazz.getName().equals(
								"com.bj58.groupbuy.action.model.ItemMetrics")) { // 新团购项目报表下载需要中间跳过几个字段项
							if (methodName.equals("getStat_date")
									|| methodName.equals("getBusiness_license")) {
								continue;
							}
						}

						if (clazz
								.getName()
								.equals("com.bj58.groupbuy.action.model.CompanyMetricsHour")) { // 新分公司报表下载需要中间跳过几个字段项
							if (methodName.equals("getStat_date")
									|| methodName.equals("getStat_hour")
									|| methodName
											.equals("getConsume_commission")
									|| methodName.equals("getSerialVersionUID")) {
								continue;
							}
						}

						if (clazz
								.getName()
								.equals("com.bj58.groupbuy.action.model.AdCityMetricsHour")
								|| clazz.getName()
										.equals("com.bj58.groupbuy.action.model.AdCityMetricsDay")) { // 广告渠道下载
																										// 从city_name字段后开始忽略

							if (methodName.equals("getCity_name")) {
								break;
							}
						}

						if (clazz
								.getName()
								.equals("com.bj58.groupbuy.action.model.KeywordMetrics")) { // 搜索关键词
							String jude = titles[0];
							if ("日期".equals(jude)) {
								if (methodName.equals("getKeyword")) {
									continue;
								}
								if (methodName.equals("getStat_hour")) {
									break;
								}
							} else if ("关键词".equals(jude)) {
								if (methodName.equals("getStat_date")) {
									continue;
								}
								if (methodName.equals("getExit_count")) {
									break;
								}
							}

						}
						if (clazz.getName().equals(
								"com.bj58.groupbuy.action.model.SHOrderStat")) { // 二手订单统计从order_count字段后开始忽略
							if (methodName.equals("getOrder_count")) {
								break;
							}
						}

						if (clazz
								.getName()
								.equals("com.bj58.groupbuy.action.model.FinanceCheckIn")) {
							if (methodName.equals("getCreate_time")) {
								break;
							}
						}

						if (clazz.getName().equals(
								"com.bj58.groupbuy.action.model.ADClickStat")) {
							if (methodName.equals("getEnt_id")) {
								break;
							}
						}

						if (clazz
								.getName()
								.equals("com.bj58.groupbuy.action.model.FinanceCheckOut")) {
							if (methodName.equals("getPmcid")) {
								value = methodMap.get("getWork_id").invoke(vo)
										.toString()
										+ "-"
										+ methodMap.get("getWork_type")
												.invoke(vo).toString();
								label = new Label(ind, i + 1, value);
								ws.addCell(label);
								ind++;
								continue;
							}
							if (methodName.equals("getWork_id")) {
								break;
							}
						}

						if (clazz.getName().equals(
								"com.bj58.groupbuy.action.model.ADClickStat")) {
							if (methodName.equals("getShop_type")) {
								value = methodMap.get(methodName).invoke(vo)
										.toString();
								if ("0".equals(value)) {
									value = "免费";
								} else if ("1".equals(value)) {
									value = "付费";
								}
								label = new Label(ind, i + 1, value);
								ws.addCell(label);
								ind++;
								continue;
							}
							if (methodName.equals("getEnt_id")) {
								break;
							}
						}

						if (clazz.getName().equals(
								"com.bj58.groupbuy.action.model.CSTaskStats")) {
							if (methodName.equals("getDone_rate")) {
								DecimalFormat df = new DecimalFormat("0.00");
								value = df
										.format(Double.valueOf(methodMap
												.get(methodName).invoke(vo)
												.toString()) * 100)
										+ "%";
								label = new Label(ind, i + 1, value);
								ws.addCell(label);
								ind++;
								continue;
							}
						}

						if (clazz
								.getName()
								.equals("com.bj58.groupbuy.action.model.CSFirsttaskStats")) {
							if (methodName.contains("rate")) {
								DecimalFormat df = new DecimalFormat("0.00");
								value = df
										.format(Double.valueOf(methodMap
												.get(methodName).invoke(vo)
												.toString()) * 100)
										+ "%";
								label = new Label(ind, i + 1, value);
								ws.addCell(label);
								ind++;
								continue;
							}
							if (methodName.equals("getCs_userId")) {
								break;
							}
						}

						if (clazz
								.getName()
								.equals("com.bj58.groupbuy.action.model.CSSecondtaskStats")) {
							if (methodName.contains("rate")) {
								DecimalFormat df = new DecimalFormat("0.00");
								value = df
										.format(Double.valueOf(methodMap
												.get(methodName).invoke(vo)
												.toString()) * 100)
										+ "%";
								label = new Label(ind, i + 1, value);
								ws.addCell(label);
								ind++;
								continue;
							}
							if (methodName.equals("getDone_byfirst")) {
								break;
							}
						}
						if (clazz.getName().equals(
								"com.bj58.groupbuy.action.model.SalerMetrics")) {
							if (methodName.equals("getGroupbuy_id")
									|| methodName.equals("getItem_name")
									|| methodName.equals("getIs_new_partner")) {
								if (null == methodMap.get(methodName)
										.invoke(vo)) {
									continue;
								} else if (methodMap.get(methodName).invoke(vo)
										.toString().equals("0")) {
									continue;
								}
							}
						}
						if (clazz
								.getName()
								.equals("com.bj58.groupbuy.action.model.GBReportGBCate")) {
							if (null == methodMap.get(methodName).invoke(vo)) {
								value = "";
							} else {
								DecimalFormat df = new DecimalFormat("0.00");
								String temp = methodMap.get(methodName)
										.invoke(vo).toString();
								if (temp.contains(".") && !temp.contains("%")) {
									value = df.format(Double.valueOf(temp));
									if (methodName.equals("getConversion_rate")) {
										value = value + "%";
									}
								} else {
									value = temp;
								}
							}
							label = new Label(ind, i + 1, value);
							ws.addCell(label);
							ind++;
							continue;
						}

						if (clazz.getName().equals(
								"com.bj58.groupbuy.action.model.ShopKpiDay")
								|| clazz.getName()
										.equals("com.bj58.groupbuy.action.model.ShopKpiHour")) {
							if (methodName.equals("getNewpvratio")) {
								break;
							}
						}

						if (clazz
								.getName()
								.equals("com.bj58.groupbuy.action.model.ShopProductStats")) {
							if (titles.length == 28) {
								if (methodName.equals("getPid")
										|| methodName.equals("getTitle")) {
									continue;
								}
							} else if (titles.length == 29) {
								if (methodName.equals("getDay")) {
									continue;
								}
							}
						}

						if (clazz
								.getName()
								.equals("com.bj58.groupbuy.action.model.PrecisionDataAll")) {
							try {
								if (null == methodMap.get(methodName)
										.invoke(vo)) {
									value = "";
								} else {
									value = methodMap.get(methodName)
											.invoke(vo).toString();
									// 百分比
									if (methodName.equals("getCTR_Channel")
											|| methodName.equals("getCTR_AD")
											|| methodName.equals("getPVR")
											|| methodName
													.equals("getMember_cost_zb")
											|| methodName
													.equals("getMember_cus_zb")) {
										isRate = 1;
									}
								}
								addExcelValue(filedCls, ws, value, isRate, ind,
										i + 1, wcfList);
							} catch (Exception e) {
								e.printStackTrace();
							} finally {
								ind++;
								continue;
							}
						}

						if (clazz
								.getName()
								.equals("com.bj58.groupbuy.action.model.PrecisionDataDetail")
								|| clazz.getName()
										.equals("com.bj58.groupbuy.action.model.PrecisionDataPFCDetail")) {
							try {
								if (null == methodMap.get(methodName)
										.invoke(vo)) {
									value = "";
								} else {
									value = methodMap.get(methodName)
											.invoke(vo).toString();
									if (methodName.equals("getState")) {
										if ("0".equals(value)) {
											value = "成功";
										} else if ("1".equals(value)) {
											value = "初始化参与拍卖";
										} else if ("2".equals(value)) {
											value = "删除状态";
										} else if ("3".equals(value)) {
											value = "出价过低";
										} else if ("4".equals(value)) {
											value = "余额不足";
										} else if ("5".equals(value)) {
											value = "推广未通过审核";
										} else if ("6".equals(value)) {
											value = "用户被封禁";
										} else if ("7".equals(value)) {
											value = "频道被删除";
										}
									}
								}
								addExcelValue(filedCls, ws, value, isRate, ind,
										i + 1, wcfList);
							} catch (Exception e) {
								e.printStackTrace();
							} finally {
								ind++;
								continue;
							}

						}

						if (clazz
								.getName()
								.equals("com.bj58.groupbuy.action.model.PrecisionDataYEBD")) {
							try {
								if (methodName.equals("getYh_cz")) {
									System.out.println("111");
								}
								if (null == methodMap.get(methodName)
										.invoke(vo)) {
									value = "";
								} else {
									value = methodMap.get(methodName)
											.invoke(vo).toString();
									if (methodName.equals("getJz_rate")) {
										isRate = 1;
									}
								}
								addExcelValue(filedCls, ws, value, isRate, ind,
										i + 1, wcfList);
							} catch (Exception e) {
								e.printStackTrace();
							} finally {
								ind++;
								continue;
							}
						}

						if (clazz
								.getName()
								.equals("com.bj58.groupbuy.action.model.PrecisionDataPCDetail")
								|| clazz.getName()
										.equals("com.bj58.groupbuy.action.model.PrecisionDataCity")) {
							try {
								if (null == methodMap.get(methodName)
										.invoke(vo)) {
									value = "";
								} else {
									value = methodMap.get(methodName)
											.invoke(vo).toString();
								}
								addExcelValue(filedCls, ws, value, isRate, ind,
										i + 1, wcfList);
							} catch (Exception e) {
								e.printStackTrace();
							} finally {
								ind++;
								continue;
							}
							// if(methodName.contains("amount")){
							// if(null == methodMap.get(methodName).invoke(vo)){
							// value ="";
							// }else{
							// DecimalFormat df = new DecimalFormat("0.0");
							// value =
							// df.format(Double.valueOf(methodMap.get(methodName).invoke(vo).toString()));
							// }
							// label = new Label(ind,i+1,value);
							// ws.addCell(label);
							// ind ++;
							// continue;
							// }
						}

						if (clazz.getName().equals(
								"com.bj58.groupbuy.action.model.ShopCheckStat")) {
							if (methodName.contains("Rate")) {
								if (null == methodMap.get(methodName)
										.invoke(vo)) {
									value = "";
								} else {
									DecimalFormat df = new DecimalFormat("0.00");
									value = df.format(Double.valueOf(methodMap
											.get(methodName).invoke(vo)
											.toString()) * 100)
											+ "%";
								}
								label = new Label(ind, i + 1, value);
								ws.addCell(label);
								ind++;
								continue;
							}
						}

						if (methodMap.containsKey(methodName)) {
							if (null == methodMap.get(methodName).invoke(vo)) {
								value = "";
							} else {
								value = methodMap.get(methodName).invoke(vo)
										.toString();
							}
						}
						label = new Label(ind, i + 1, value);
						ws.addCell(label);
						ind++;
					}
				}
			}
			return wwb;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	*//**
	 * 通用报表excel下载2 : 按照查询的cols对其进行下载
	 * 
	 * @param <T>
	 * @param excelname
	 *            报表名
	 * @param cols
	 *            查询项（列标集合）
	 * @param dic
	 *            该VO各字段中英文对照字典
	 * @param rsList
	 *            数据集合
	 * @param clazz
	 * @return
	 *//*
	public static <T> WritableWorkbook writeExcelCommon2(String excelname,
			HttpServletResponse response, List<String> cols, String dic,
			List<T> rsList, Class<T> clazz) {
		// VelocityTools vt = new VelocityTools();
		try {
			OutputStream os = response.getOutputStream();
			WritableWorkbook wwb = Workbook.createWorkbook(os);

			List<String> titles = new ArrayList<String>();// 列标题集合
			String[] dics = dic.split(";");
			Map<String, String> dcMap = new HashMap<String, String>();
			for (String dc : dics) {
				String ename = dc.split(":")[0];
				String cname = dc.split(":")[1];
				dcMap.put(ename, cname);
			}
			for (String col : cols) {
				if (dcMap.containsKey(col)) {
					titles.add(dcMap.get(col));
				}
			}

			Map<Integer, List<T>> rsMap = new HashMap<Integer, List<T>>();
			int sheetMaxNum = 60000;
			if (rsList.size() > sheetMaxNum) {
				int sheetCount = rsList.size() / sheetMaxNum;
				if (rsList.size() % sheetMaxNum > 0) {
					sheetCount++;
				}
				for (int i = 0; i < sheetCount; i++) {
					int beginIndex = i * sheetMaxNum;
					int endIndex = (i + 1) * sheetMaxNum;
					if (endIndex > rsList.size()) {
						endIndex = rsList.size();
					}
					rsMap.put(i, rsList.subList(beginIndex, endIndex));
				}
			} else {
				rsMap.put(0, rsList);
			}
			Iterator<Integer> rsKey = rsMap.keySet().iterator();
			while (rsKey.hasNext()) {
				int sheetNum = rsKey.next();
				List<T> subrsList = rsMap.get(sheetNum);
				String sheetName = "";
				if (sheetNum == 0) {
					sheetName = excelname;
				} else {
					sheetName = excelname + "_" + sheetNum;
				}
				WritableSheet ws = wwb.createSheet(sheetName, sheetNum);
				// 写列标
				Label label = new Label(0, 0, titles.get(0));
				ws.addCell(label);
				for (int i = 1; i < titles.size(); i++) {
					label = new Label(i, 0, titles.get(i));
					ws.addCell(label);
				}
				// 写内容
				Method[] mm = clazz.getMethods();
				Map<String, Method> methodMap = new HashMap<String, Method>();
				for (Method m : mm) {
					methodMap.put(m.getName(), m);
				}

				// WritableCellFormat 数字格式问题处理
				List<WritableCellFormat> wcfList = getWCFList();

				for (int i = 0; i < subrsList.size(); i++) {
					T vo = subrsList.get(i);
					int ind = 0;
					for (int j = 0; j < cols.size(); j++) {
						try {
							String value = "";
							String methodName = "get"
									+ cols.get(j).substring(0, 1).toUpperCase()
									+ cols.get(j).substring(1);
							Class<?> filedCls = clazz.getDeclaredField(
									cols.get(j)).getType();
							int isRate = 0;// 是否为百分比 默认不是

							if (clazz
									.getName()
									.equals("com.bj58.groupbuy.action.model.GBReportByCate")
									|| clazz.getName()
											.equals("com.bj58.groupbuy.action.model.GBReportByArea")
									|| clazz.getName()
											.equals("com.bj58.groupbuy.action.model.GBReportByFlow")
									|| clazz.getName()
											.equals("com.bj58.groupbuy.action.model.HYAreaReport")
									|| clazz.getName()
											.equals("com.bj58.groupbuy.action.model.HYCateReport")
									|| clazz.getName()
											.equals("com.bj58.groupbuy.action.model.HYTotalReport")) {
								if (null == methodMap.get(methodName)
										.invoke(vo)) {
									value = "";
								} else {
									DecimalFormat df = new DecimalFormat("0.00");
									String temp = methodMap.get(methodName)
											.invoke(vo).toString();
									if (temp.contains(".")
											&& !temp.contains("%")) {
										value = df.format(Double.valueOf(temp));
										if (methodName
												.equals("getConversion_rate")
												|| methodName
														.equals("getPay_commission_rate")) {
											value = value + "%";
										}
									} else {
										value = temp;
									}
								}
								label = new Label(ind, i + 1, value);
								ws.addCell(label);
								continue;
							}

							if (clazz
									.getName()
									.equals("com.bj58.groupbuy.action.model.PrecisionKpi")) {
								if (null == methodMap.get(methodName)
										.invoke(vo)) {
									value = "";
								} else {
									value = methodMap.get(methodName)
											.invoke(vo).toString();
									// 百分比
									String ename = cols.get(j);
									String cname = dcMap.get(ename);
									if (cname.equals("PVR")
											|| cname.equals("CTR（频道）")
											|| cname.equals("CTR(广告)")
											|| cname.equals("精准消费占比")
											|| cname.equals("会员消费占比")
											|| cname.equals("会员客户数占比")) {
										isRate = 1;
									}
								}
								addExcelValue(filedCls, ws, value, isRate, ind,
										i + 1, wcfList);
								continue;
							}

							if (methodMap.containsKey(methodName)) {
								if (null == methodMap.get(methodName)
										.invoke(vo)) {
									value = "";
								} else {
									value = methodMap.get(methodName)
											.invoke(vo).toString();
								}
							}

							label = new Label(ind, i + 1, value);
							ws.addCell(label);
						} catch (Exception e) {
							e.printStackTrace();
							continue;
						} finally {
							ind++;
						}
					}
				}
			}
			return wwb;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public static List<String> readExcel(String filePath) throws Exception {
		if (filePath.contains("csv")) { // CSV文件
			return readCsv(filePath, "GB2312");
		}
		List<String> list = new ArrayList<String>();
		InputStream fs = new FileInputStream(filePath);
		Workbook workBook = Workbook.getWorkbook(fs);
		// getSheets() 方法返回 Sheet[] 数组 然后利用数组来操作。
		Sheet[] sheets = workBook.getSheets();// 获取所有SHEET
		for (Sheet sheet : sheets) {
			Cell cell = null;// 就是单个单元格
			// 开始循环，取得 cell 里的内容，这里都是按String来取的 为了省事
			for (int j = 0; j < sheet.getRows(); j++) {
				StringBuffer sb = new StringBuffer();
				for (int i = 0; i < sheet.getColumns(); i++) {
					cell = sheet.getCell(i, j);
					sb.append(cell.getContents());
					sb.append("@");// 将单元格的每行内容隔开
				}
				String check = sb.toString().replace("@", "").trim();
				if ("".equals(check)) { // 无数据不放入
					continue;
				}
				list.add(sb.toString().substring(0,
						sb.toString().lastIndexOf("@")));// 将每行的字符串用一个String类型的集合保存。
			}
		}
		workBook.close();// 关闭
		return list;
	}

	public static List<String> readExcel(InputStream fs) throws Exception {
		List<String> list = new ArrayList<String>();
		Workbook workBook = Workbook.getWorkbook(fs);
		// getSheets() 方法返回 Sheet[] 数组 然后利用数组来操作。
		Sheet[] sheets = workBook.getSheets();// 获取所有SHEET
		for (Sheet sheet : sheets) {
			Cell cell = null;// 就是单个单元格
			// 开始循环，取得 cell 里的内容，这里都是按String来取的 为了省事
			for (int j = 0; j < sheet.getRows(); j++) {
				StringBuffer sb = new StringBuffer();
				for (int i = 0; i < sheet.getColumns(); i++) {
					cell = sheet.getCell(i, j);
					String cellCont = StringUtils.strip(cell.getContents());
					if(!StringUtils.equals(cellCont, "--")){
						sb.append(cellCont);
					}
					sb.append("@");// 将单元格的每行内容隔开
				}
				String check = sb.toString().replace("@", "").trim();
				if ("".equals(check)) { // 无数据不放入
					continue;
				}
				list.add(sb.toString().substring(0,
						sb.toString().lastIndexOf("@")));// 将每行的字符串用一个String类型的集合保存。
			}
		}
		workBook.close();// 关闭
		return list;
	}

	public static <T> WritableWorkbook addExcel(List<T> rsList, Class<T> clazz,
			String pathName, String newPath) throws Exception {
		Workbook book = Workbook.getWorkbook(new File(pathName));
		Sheet sheet = book.getSheet(0);
		// 获取行
		int length = sheet.getRows();
		WritableWorkbook wbook = Workbook.createWorkbook(new File(newPath),
				book); // 根据book创建一个操作对象
		WritableSheet sh = wbook.getSheet(0);// 得到一个工作对象

		// 对象方法
		Method[] mm = clazz.getMethods();
		Map<String, Method> methodMap = new HashMap<String, Method>();
		for (Method m : mm) {
			methodMap.put(m.getName(), m);
		}
		Field[] fields = clazz.getDeclaredFields();

		// 从最后一行开始加
		for (int i = 0; i < rsList.size(); i++) {
			T vo = rsList.get(i);
			int ind = 0;
			for (int j = 0; j < fields.length; j++) {
				Label label = null;
				String value = "";
				String methodName = "get"
						+ fields[j].getName().substring(0, 1).toUpperCase()
						+ fields[j].getName().substring(1);
				if (clazz.getName().equals(
						"com.bj58.groupbuy.action.model.PrecisionDataAll")) {
					if (null == methodMap.get(methodName).invoke(vo)) {
						value = "";
					} else {
						if (methodName.equals("getCTR_Channel")
								|| methodName.equals("getCTR_AD")
								|| methodName.equals("getPVR")
								|| methodName.equals("getMember_cost_zb")
								|| methodName.equals("getMember_cus_zb")) {
							value = methodMap.get(methodName).invoke(vo)
									.toString()
									+ "%";
						} else {
							value = methodMap.get(methodName).invoke(vo)
									.toString();
						}
					}
					label = new Label(ind, i + length, value);
					sh.addCell(label);
					ind++;
					continue;
				}

				if (methodMap.containsKey(methodName)) {
					if (null == methodMap.get(methodName).invoke(vo)) {
						value = "";
					} else {
						value = methodMap.get(methodName).invoke(vo).toString();
					}
				}
				label = new Label(ind, i + length, value);
				sh.addCell(label);
				ind++;
			}
		}
		return wbook;
	}

	*//**
	 * 智能通用报表excel下载
	 * 
	 * @param <T>
	 * @param excelname
	 *            报表名
	 * @param response
	 *            不为NULL则生成WWB以供下载 为NULL则配合pathName生成EXCEL文件保存
	 * @param titles
	 *            标题集合
	 * @param rsList
	 *            值集合
	 * @param pathName
	 *            EXCEL文件生成路径 无需则为空""
	 * @return
	 *//*
	public static <T> WritableWorkbook writeExcelCommonForIR(String excelname,
			HttpServletResponse response, List<String> titles,
			List<String> rsList, String pathName) {
		try {
			WritableWorkbook wwb = null;
			if (null != response) {
				OutputStream os = response.getOutputStream();
				wwb = Workbook.createWorkbook(os);
			} else {
				wwb = Workbook.createWorkbook(new File(pathName));
			}

			// OutputStream os = response.getOutputStream();
			// WritableWorkbook wwb = Workbook.createWorkbook(os);

			Map<Integer, List<String>> rsMap = new HashMap<Integer, List<String>>();
			int sheetMaxNum = 60000;
			if (rsList.size() > sheetMaxNum) {
				int sheetCount = rsList.size() / sheetMaxNum;
				if (rsList.size() % sheetMaxNum > 0) {
					sheetCount++;
				}
				for (int i = 0; i < sheetCount; i++) {
					int beginIndex = i * sheetMaxNum;
					int endIndex = (i + 1) * sheetMaxNum;
					if (endIndex > rsList.size()) {
						endIndex = rsList.size();
					}
					rsMap.put(i, rsList.subList(beginIndex, endIndex));
				}
			} else {
				rsMap.put(0, rsList);
			}

			Iterator<Integer> rsKey = rsMap.keySet().iterator();
			while (rsKey.hasNext()) {
				int sheetNum = rsKey.next();
				List<String> subrsList = rsMap.get(sheetNum);
				String sheetName = "";
				if (sheetNum == 0) {
					sheetName = excelname;
				} else {
					sheetName = excelname + "_" + sheetNum;
				}
				WritableSheet ws = wwb.createSheet(sheetName, sheetNum);
				// 写列标
				Label label = new Label(0, 0, titles.get(0).substring(0,
						titles.get(0).indexOf(":")));
				ws.addCell(label);
				for (int i = 1; i < titles.size(); i++) {
					label = new Label(i, 0, titles.get(i).substring(0,
							titles.get(i).indexOf(":")));
					ws.addCell(label);
				}
				List<WritableCellFormat> wcfList = getWCFList();
				for (int i = 0; i < subrsList.size(); i++) {
					String temp = subrsList.get(i);
					String[] value = temp.split(";");
					for (int j = 0; j < value.length; j++) {
						String result = "";
						try {
							result = value[j].split(",")[0];
							int type = Integer.parseInt(value[j].split(",")[1]);
							switch (type) {
							case 1: // 整型
								if ("--".equals(result)) {
									result = "0";
								}
								Number doubleNum = new Number(j, i + 1,
										Double.valueOf(result), wcfList.get(1));
								ws.addCell(doubleNum);
								break;
							case 2: // 浮点
								if ("--".equals(result)) {
									result = "0";
								}
								Number doubleNum2 = new Number(j, i + 1,
										Double.valueOf(result), wcfList.get(2));
								ws.addCell(doubleNum2);
								break;
							case 3: // 百分比
								if ("--".equals(result)) {
									label = new Label(j, i + 1, result);
									ws.addCell(label);
								} else {
									Number doubleNum3 = new Number(j, i + 1,
											Double.valueOf(result),
											wcfList.get(0));
									ws.addCell(doubleNum3);
								}
								break;

							case 4: // 长数字（无需千分位隔开处理）
								if ("--".equals(result)) {
									result = "0";
								}
								Number doubleNum4 = new Number(j, i + 1,
										Double.valueOf(result), wcfList.get(3));
								ws.addCell(doubleNum4);
								break;
							default:
								label = new Label(j, i + 1, result);
								ws.addCell(label);
								break;
							}
						} catch (Exception e) {
							e.printStackTrace();
							continue;
						}
					}
				}
			}
			return wwb;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	*//**
	 * 智能通用报表excel下载
	 * 
	 * @param <T>
	 * @param excelname
	 *            报表名
	 * @param response
	 *            不为NULL则生成WWB以供下载 为NULL则配合pathName生成EXCEL文件保存
	 * @param titles
	 *            标题集合
	 * @param rsList
	 *            值集合
	 * @param pathName
	 *            EXCEL文件生成路径 无需则为空""
	 * @param gbCount
	 *            分组维度个数
	 * @param keyValue
	 *            维度值--数据值
	 * @param dayRatio
	 *            是否含有日环比
	 * @param weekRatio
	 *            是否含有周同比
	 * @return
	 *//*
	public static <T> WritableWorkbook writeExcelCommonForIRWithRatio(
			String excelname, HttpServletResponse response,
			List<String> titles, List<String> rsList,
			HashMap<String, String> keyValue, int gbCount, String pathName,
			boolean dayRatio, boolean weekRatio,int statgrpindex) {
		try {
			WritableWorkbook wwb = null;
			if (null != response) {
				OutputStream os = response.getOutputStream();
				wwb = Workbook.createWorkbook(os);
			} else {
				wwb = Workbook.createWorkbook(new File(pathName));
			}

			// OutputStream os = response.getOutputStream();
			// WritableWorkbook wwb = Workbook.createWorkbook(os);

			Map<Integer, List<String>> rsMap = new HashMap<Integer, List<String>>();
			int sheetMaxNum = 60000;
			if (rsList.size() > sheetMaxNum) {
				int sheetCount = rsList.size() / sheetMaxNum;
				if (rsList.size() % sheetMaxNum > 0) {
					sheetCount++;
				}
				for (int i = 0; i < sheetCount; i++) {
					int beginIndex = i * sheetMaxNum;
					int endIndex = (i + 1) * sheetMaxNum;
					if (endIndex > rsList.size()) {
						endIndex = rsList.size();
					}
					rsMap.put(i, rsList.subList(beginIndex, endIndex));
				}
			} else {
				rsMap.put(0, rsList);
			}

			Iterator<Integer> rsKey = rsMap.keySet().iterator();
			while (rsKey.hasNext()) {
				int sheetNum = rsKey.next();
				List<String> subrsList = rsMap.get(sheetNum);
				String sheetName = "";
				if (sheetNum == 0) {
					sheetName = excelname;
				} else {
					sheetName = excelname + "_" + sheetNum;
				}
				WritableSheet ws = wwb.createSheet(sheetName, sheetNum);
				// 写列标
				Label label = new Label(0, 0, titles.get(0).substring(0,
						titles.get(0).indexOf(":")));
				ws.addCell(label);
				int col = 0;
				for (int i = 1; i < titles.size(); i++) {
					String title = titles.get(i);
					label = new Label(++col, 0, title.substring(0,
							title.indexOf(":")));
					int type = Integer.parseInt(title.substring(title
							.indexOf(":") + 1,title.indexOf(":")+2));
					ws.addCell(label);
					if (type != 0) {
						if (dayRatio) {
							label = new Label(++col, 0, "日环比");
							ws.addCell(label);
						}
						if (weekRatio) {
							label = new Label(++col, 0, "周同比");
							ws.addCell(label);
						}
					}
				}
				List<WritableCellFormat> wcfList = getWCFList();
				for (int i = 0; i < subrsList.size(); i++) {
					String temp = subrsList.get(i);
					String[] value = temp.split(";");
					String currentDate = value[statgrpindex].split(",")[0];
					String keyOfYestoday="";
			    	String keyOfLastWeek="";
			    	String Yestodaystr=DateUtil.strToStrBefore(currentDate,"yyyy-MM-dd", 1);
			    	String LastWeekstr=DateUtil.strToStrBefore(currentDate,"yyyy-MM-dd", 7);
					for (int k = 0; k < gbCount; k++) {
						if(k!=statgrpindex)//如果不是日期
			    		{
							keyOfYestoday += value[k].split(",")[0];
							keyOfLastWeek += value[k].split(",")[0];
							if (k + 1 < gbCount) {
								keyOfYestoday += "_";
								keyOfLastWeek += "_";
							}
			    		}else{
			    			keyOfYestoday+=Yestodaystr;
			    			keyOfLastWeek+=LastWeekstr;
			    			if(k+1<gbCount){
				    			keyOfYestoday+="_";
				        		keyOfLastWeek+="_";
				    		}
			    		}
					}
					col = 0;
					for (int j = 0; j < value.length; j++) {
						String result = "";
						try {
							result = value[j].split(",")[0];
							int type = Integer.parseInt(value[j].split(",")[1]);
							switch (type) {
							case 1: // 整型
								if ("--".equals(result)) {
									result = "0";
								}
								Number doubleNum = new Number(col++, i + 1,
										Double.valueOf(result), wcfList.get(1));
								ws.addCell(doubleNum);
								break;
							case 2: // 浮点
								if ("--".equals(result)) {
									result = "0";
								}
								Number doubleNum2 = new Number(col++, i + 1,
										Double.valueOf(result), wcfList.get(2));
								ws.addCell(doubleNum2);
								break;
							case 3: // 百分比
								if ("--".equals(result)) {
									label = new Label(col++, i + 1, result);
									ws.addCell(label);
								} else {
									Number doubleNum3 = new Number(col++,
											i + 1, Double.valueOf(result),
											wcfList.get(0));
									ws.addCell(doubleNum3);
								}
								break;

							case 4: // 长数字（无需千分位隔开处理）
								if ("--".equals(result)) {
									result = "0";
								}
								Number doubleNum4 = new Number(col++, i + 1,
										Double.valueOf(result), wcfList.get(3));
								ws.addCell(doubleNum4);
								break;
							default:
								label = new Label(col++, i + 1, result);
								ws.addCell(label);
								break;
							}
							if (type != 0) {
								if (dayRatio)
									ws.addCell(comRatio(keyValue,
											keyOfYestoday, result, gbCount, j,
											col++, i + 1, wcfList.get(0)));
								if (weekRatio)
									ws.addCell(comRatio(keyValue,
											keyOfLastWeek, result, gbCount, j,
											col++, i + 1, wcfList.get(0)));
							}
						} catch (Exception e) {
							e.printStackTrace();
							continue;
						}
					}
				}
			}
			return wwb;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	*//**
	 * 智能通用报表excel下载,同步方法
	 * 
	 * @param <T>
	 * @param excelname
	 *            报表名
	 * @param response
	 *            不为NULL则生成WWB以供下载 为NULL则配合pathName生成EXCEL文件保存
	 * @param titles
	 *            标题集合
	 * @param rsList
	 *            值集合
	 * @param pathName
	 *            EXCEL文件生成路径 无需则为空""
	 * @param gbCount
	 *            分组维度个数
	 * @param keyValue
	 *            维度值--数据值
	 * @param dayRatio
	 *            是否含有日环比
	 * @param weekRatio
	 *            是否含有周同比
	 * @return
	 *//*
	public synchronized static <T> WritableWorkbook writeExcelCommonWithRatioSync(
			String excelname, HttpServletResponse response,
			List<String> titles, List<String> rsList,
			HashMap<String, String> keyValue, int gbCount, String pathName,
			boolean dayRatio, boolean weekRatio) {
		try {
			if (keyValue == null)
				return writeExcelCommonForIR(excelname, null, titles, rsList,
						pathName);
			WritableWorkbook wwb = null;
			if (null != response) {
				OutputStream os = response.getOutputStream();
				wwb = Workbook.createWorkbook(os);
			} else {
				wwb = Workbook.createWorkbook(new File(pathName));
			}

			// OutputStream os = response.getOutputStream();
			// WritableWorkbook wwb = Workbook.createWorkbook(os);

			Map<Integer, List<String>> rsMap = new HashMap<Integer, List<String>>();
			int sheetMaxNum = 60000;
			if (rsList.size() > sheetMaxNum) {
				int sheetCount = rsList.size() / sheetMaxNum;
				if (rsList.size() % sheetMaxNum > 0) {
					sheetCount++;
				}
				for (int i = 0; i < sheetCount; i++) {
					int beginIndex = i * sheetMaxNum;
					int endIndex = (i + 1) * sheetMaxNum;
					if (endIndex > rsList.size()) {
						endIndex = rsList.size();
					}
					rsMap.put(i, rsList.subList(beginIndex, endIndex));
				}
			} else {
				rsMap.put(0, rsList);
			}

			Iterator<Integer> rsKey = rsMap.keySet().iterator();
			while (rsKey.hasNext()) {
				int sheetNum = rsKey.next();
				List<String> subrsList = rsMap.get(sheetNum);
				String sheetName = "";
				if (sheetNum == 0) {
					sheetName = excelname;
				} else {
					sheetName = excelname + "_" + sheetNum;
				}
				WritableSheet ws = wwb.createSheet(sheetName, sheetNum);
				// 写列标
				Label label = new Label(0, 0, titles.get(0).substring(0,
						titles.get(0).indexOf(":")));
				ws.addCell(label);
				int col = 0;
				for (int i = 1; i < titles.size(); i++) {
					String title = titles.get(i);
					label = new Label(++col, 0, title.substring(0,
							title.indexOf(":")));
					int type = Integer.parseInt(title.substring(title
							.indexOf(":") + 1));
					ws.addCell(label);
					if (type != 0) {
						if (dayRatio) {
							label = new Label(++col, 0, "日环比");
							ws.addCell(label);
						}
						if (weekRatio) {
							label = new Label(++col, 0, "周同比");
							ws.addCell(label);
						}
					}
				}
				List<WritableCellFormat> wcfList = getWCFList();
				for (int i = 0; i < subrsList.size(); i++) {
					String temp = subrsList.get(i);
					String[] value = temp.split(";");
					String currentDate = null;
					String keyOfYestoday = null;
					String keyOfLastWeek = null;
					if (dayRatio || weekRatio) {
						currentDate = value[0].split(",")[0];
						keyOfYestoday = DateUtil.strToStrBefore(currentDate,
								"yyyy-MM-dd", 1);
						keyOfLastWeek = DateUtil.strToStrBefore(currentDate,
								"yyyy-MM-dd", 7);
						if (gbCount > 1) {
							keyOfYestoday += "_";
							keyOfLastWeek += "_";
						}
						for (int k = 1; k < gbCount; k++) {
							keyOfYestoday += value[k].split(",")[0];
							keyOfLastWeek += value[k].split(",")[0];
							if (k + 1 < gbCount) {
								keyOfYestoday += "_";
								keyOfLastWeek += "_";
							}
						}
					}
					col = 0;
					for (int j = 0; j < value.length; j++) {
						String result = "";
						try {
							result = value[j].split(",")[0];
							int type = Integer.parseInt(value[j].split(",")[1]);
							switch (type) {
							case 1: // 整型
								if ("--".equals(result)) {
									result = "0";
								}
								Number doubleNum = new Number(col++, i + 1,
										Double.valueOf(result), wcfList.get(1));
								ws.addCell(doubleNum);
								break;
							case 2: // 浮点
								if ("--".equals(result)) {
									result = "0";
								}
								Number doubleNum2 = new Number(col++, i + 1,
										Double.valueOf(result), wcfList.get(2));
								ws.addCell(doubleNum2);
								break;
							case 3: // 百分比
								if ("--".equals(result)) {
									label = new Label(col++, i + 1, result);
									ws.addCell(label);
								} else {
									Number doubleNum3 = new Number(col++,
											i + 1, Double.valueOf(result),
											wcfList.get(0));
									ws.addCell(doubleNum3);
								}
								break;

							case 4: // 长数字（无需千分位隔开处理）
								if ("--".equals(result)) {
									result = "0";
								}
								Number doubleNum4 = new Number(col++, i + 1,
										Double.valueOf(result), wcfList.get(3));
								ws.addCell(doubleNum4);
								break;
							default:
								label = new Label(col++, i + 1, result);
								ws.addCell(label);
								break;
							}
							if (type != 0) {
								if (dayRatio)
									ws.addCell(comRatio(keyValue,
											keyOfYestoday, result, gbCount, j,
											col++, i + 1, wcfList.get(0)));
								if (weekRatio)
									ws.addCell(comRatio(keyValue,
											keyOfLastWeek, result, gbCount, j,
											col++, i + 1, wcfList.get(0)));
							}
						} catch (Exception e) {
							e.printStackTrace();
							continue;
						}
					}
				}
			}
			return wwb;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	*//**
	 * Excel值写入
	 * 
	 * @param filedCls
	 *            字段类别
	 * @param ws
	 *            Excel表写入对象
	 * @param value
	 *            值
	 * @param isRate
	 *            是否为百分比 0 : 否 1：是
	 * @param col
	 * @param row
	 * @return
	 * @throws Exception
	 *//*
	private static boolean addExcelValue(Class<?> filedCls, WritableSheet ws,
			String value, int isRate, int col, int row,
			List<WritableCellFormat> wcfList) throws Exception {
		WritableCellFormat wcf = null;
		try {
			if (isRate == 1) {
				wcf = wcfList.get(0);
				Number doubleNum = new Number(col, row,
						Double.valueOf(value) / 100, wcf);
				ws.addCell(doubleNum);
			} else {
				if (filedCls == Integer.class || filedCls == int.class) {// 整型短数字
					wcf = wcfList.get(1);
					Number doubleNum = new Number(col, row,
							Double.valueOf(value), wcf);
					ws.addCell(doubleNum);
				} else if (filedCls == Double.class || filedCls == double.class) {// 小数点
					wcf = wcfList.get(2);
					Number doubleNum = new Number(col, row,
							Double.valueOf(value), wcf);
					ws.addCell(doubleNum);
				} else if (filedCls == String.class) {
					Label label = new Label(col, row, value);
					ws.addCell(label);
				} else if (filedCls == Long.class || filedCls == long.class) { // 整型长数字
					if (value.length() > 15) {// 超过15位则用字符格式
						Label label = new Label(col, row, value);
						ws.addCell(label);
					} else {
						wcf = wcfList.get(3);
						Number doubleNum = new Number(col, row,
								Double.valueOf(value), wcf);
						ws.addCell(doubleNum);
					}
				}
			}
			return true;
		} catch (Exception e) {
			return false;
		}
	}

	private static List<WritableCellFormat> getWCFList() {
		List<WritableCellFormat> wcfList = new ArrayList<WritableCellFormat>();

		WritableCellFormat format1 = null; // 百分比格式
		NumberFormat nf1 = new NumberFormat("0.00%");
		format1 = new WritableCellFormat(nf1);
		wcfList.add(format1);

		WritableCellFormat format2 = new WritableCellFormat(
				NumberFormats.THOUSANDS_INTEGER); // 整型千分位格式
		wcfList.add(format2);

		WritableCellFormat format3 = null;
		; // 浮点2位小数
		NumberFormat nf3 = new NumberFormat("0.00");
		format3 = new WritableCellFormat(nf3);
		wcfList.add(format3);

		WritableCellFormat format4 = new WritableCellFormat(
				NumberFormats.INTEGER); // 整型长数字 (不超过15)
		wcfList.add(format4);

		return wcfList;
	}

	public static List<String> readCsv(String filePath, String charsetName)
			throws Exception {
		List<String> rsList = new ArrayList<String>();
		FileInputStream fis = new FileInputStream(filePath);
		InputStreamReader in = new InputStreamReader(fis, charsetName);
		BufferedReader reader = new BufferedReader(in);// 换成你的文件名
		String line = null;

		reader.read();
		while ((line = reader.readLine()) != null) {
			if ("GB2312".equals(charsetName)) {
				line = line.replace(",", "@");
			} else if ("unicode".equals(charsetName)) {
				line = line.replaceAll("\\t", "@");
			}
			String check = line.toString().replace("@", "").trim();
			if ("".equals(check)) { // 无数据不放入
				continue;
			}
			rsList.add(line);
		}
		return rsList;
	}

	*//**
	 * 把VOLIST 转为 字符串+数据类型的形式 供写入EXCEL
	 * 
	 * @param <T>
	 * @param clazz
	 * @param rsList
	 * @param percentList
	 *            百分比字段List
	 * @param tranCols
	 *            需要转换的字段集合 为NULL则为VO全部字段
	 * @return
	 * @throws Exception
	 *//*
	@SuppressWarnings("static-access")
	public <T> List<String> tranVoToString(Class<T> clazz, List<T> rsList,
			List<String> percentList, List<String> tranCols) throws Exception {
		List<String> finalList = new ArrayList<String>();

		Field[] fs = clazz.getDeclaredFields();// CLAZZ所有字段
		List<String> fdNameList = new ArrayList<String>();// 最终需转换的字段名集合
		if (null == tranCols) { // 默认全部字段
			for (Field fd : fs) {
				String fdName = fd.getName();
				fdNameList.add(fdName);
			}
		} else {
			fdNameList = tranCols;
		}

		for (T vo : rsList) {
			StringBuffer values = new StringBuffer();
			for (String fdName : fdNameList) {
				// 字段数据
				Object nowData = reflectUtil.getGetterMethod(clazz,
						clazz.getDeclaredField(fdName)).invoke(vo);
				// 字段数据类型
				Field field = clazz.getDeclaredField(fdName);
				Class<?> filedCls = field.getType();
				int colType = 0; // 数据类型 0 :字符串 1: 整型 2：浮点 3：百分比
				if (filedCls == int.class || filedCls == Integer.class
						|| filedCls == long.class || filedCls == Long.class) {
					colType = 1;
				} else if (filedCls == double.class || filedCls == Double.class) {
					if (null != percentList && percentList.contains(fdName)) {
						colType = 3;
					} else {
						colType = 2;
					}
				} else if (fdName.contains("_hb") || fdName.contains("_tb")) { // 已经转换为字符串类型的
																				// 百分比数据
																				// 环比/同比
					if (null == nowData) {
						nowData = "0%";
					}
					String temp = nowData.toString();
					temp = temp.substring(0, temp.indexOf("%"));
					double tempValue = Double.valueOf(temp) / 100;
					nowData = tempValue;
					colType = 3;
				}

				if ("userId".equals(fdName)) {
					colType = 0;
				}

				if (null != nowData) {
					values.append(nowData.toString() + "," + colType + ";");
				} else {
					values.append("--" + ",0;");
				}
			}

			if (values.toString().split(";").length > 1) {
				finalList.add(values.toString());
			}
		}
		return finalList;
	}

	*//**
	 * 计算换同比
	 * 
	 * @param groupBy_Values
	 * @param key
	 * @param cellValue
	 * @param gbCount
	 * @param index
	 * @param c
	 * @param r
	 * @param format
	 * @return
	 *//*
	public static WritableCell comRatio(HashMap<String, String> groupBy_Values,
			String key, String cellValue, int gbCount, int index, int c, int r,
			WritableCellFormat format) {
		WritableCell cell = null;
		// System.out.println(key+"----"+r+","+c+": "+cellValue);
		if (index < gbCount || "--".equals(cellValue))
			return new Label(c, r, "--");
		DecimalFormat df = new DecimalFormat("0.0000");
		String[] values = groupBy_Values.get(key) == null ? null
				: groupBy_Values.get(key).split(";");
		int realindex = index - gbCount;
		String ratio = "--";
		double todayV = Double.parseDouble(cellValue);
		if (values != null && realindex >= 0)
			if (realindex >= values.length
					|| "--".equals(values[realindex].split(",")[0]))
				ratio = "--";
			else {
				String tmp = values[realindex].split(",")[0];
				double result = Double.parseDouble(tmp);
				if (result > 0) {
					ratio = df.format((todayV - result) / result);
				}
			}
		if (ratio.equals("--")) {
			cell = new Label(c, r, ratio);
		} else
			cell = new Number(c, r, Double.parseDouble(ratio), format);
		return cell;
	}
}
*/